<template>
	<m-layout-scroll title="分享好友">
		<m-text @click="Jump('/pages/mine/myteam/myteam')" slot="right">已邀请好友</m-text>
		<view class="share-box align-center">
			<m-block class="inline-block" spa="20 0 ">
				<u-qrcode ref="qrcode" size='123' canvas-id="qrcode" :options='{ margin:10 }' :value="shareUrl" />
			</m-block>
			<m-text ftsize="24" color="#5639D5" block>长按识别或扫描二维码</m-text>
		</view>
		<m-block gap="60 40" bgColor="unset" slot='footer'>
			<m-text ftsize="32" bold color="#5639D5" block>邀请码：{{userinfo.invcode}}</m-text>
			<m-text ftsize="32" spa='20 0' bold color="#5639D5" block class="otw">邀请地址：{{shareUrl}}...</m-text>
			
			<m-button  block>分享给好友</m-button>
			<!-- <button class="share-btn" open-type="share" @onShareAppMessage="onShareAppMessage">分享给好友</button> -->
		</m-block>
	</m-layout-scroll>
</template>

<script>
	import { mapState } from 'vuex'
import { UserInfo } from '@/api/Users';
	export default {
		data() {
			return {

			};

		},
		computed: {
			...mapState({
				userinfo: state => state.user.userinfo,
				config: state => state.general.config,
			}),
			config999() {
				return this.config[999]
			},
			shareUrl() {
				return this.config999 + '/h5pro/?invcode=' + this.userinfo.invcode;
			},
		},
		onLoad() {
			this.init()
		},
		methods: {
			async init() {
				UserInfo()
			},
			onShareAppMessage() {
				return {
					title: '同在优选·您身边的健康小管家', // 默认是小程序的名称(可以写slogan等)
					path: '/h5pro?invcode=' + this.userinfo.invcode, // 点击链接进入的页面
					imageUrl: 'https://files.hcypai.com/static/imgs/share-banner.png', //自定义图片路径，可以是本地文件路径、代码包文件路径或者网络图片路径，支持PNG及JPG，不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
					success: function(res) {
						// 转发成功
						console.log("转发成功", res);
					},
					fail: function(res) {
						// 转发失败
						console.log("转发失败", res);
					}
				};
			}
		},
		onPullDownRefresh() {
			this.init();
		},



	}
</script>

<style lang="scss">
	page {
		// background: url('/static/images/pages/home/sharebg.png') no-repeat;
		background-size: 100% auto;
	}

	.share-box {
		position: relative;
		z-index: 9;
		padding: 24rpx;
		padding-top: 40%;

	}

	image {
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
	}

	.msg-box {
		box-sizing: border-box;
		padding-bottom: 40rpx;
		border-bottom: 1rpx dashed #E4E4E4;

		.right {
			flex: 1;
			padding-left: 25rpx;
			overflow: hidden;

			.shareUrl {
				padding-top: 10rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #333333;
			}
		}
	}

	.share-btn {
		width: 100%;
		margin: 100rpx 0 0rpx;
		display: inline-block;
		border-width: 0.5px;
		border-style: solid;
		border-color: var(--theme);
		border-image: initial;
		font-size: 26rpx;
		font-family: "PingFang SC", "PingFang SC";
		padding: 20rpx 34rpx;
		border-radius: 10rpx;
		transform: rotate(0deg);
		background: var(--theme);
		color: #fff;
		line-height: unset;

		&::after {
			display: none;
		}

	}
</style>